<%@ page contentType="text/html; charset=UTF-8" session="true" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>

<%
    String username = request.getParameter("username");
    String password = request.getParameter("password");

    // 模拟设定的账号和密码
    String expectedUsername = "admin";
    String expectedPassword = "123456";

    if (username.equals(expectedUsername) && password.equals(expectedPassword)) {
        session.setAttribute("username", username);
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Page 2</title>
</head>
<body>
    <h1>欢迎您, <%= username %></h1>
    <form action="page3.jsp" method="post">
        <label for="name">请输入姓名:</label>
        <input type="text" id="name" name="name" required><br><br>

        <input type="submit" value="提交">
    </form>
</body>
</html>
<%
    } else {
        response.sendRedirect("login.jsp");
    }
%>
